/*
 * ItemSearchOptions.java
 */

package nxtgeninventorysystem.Data;

/**
 * The ItemSearchOptions class is meant to hold data that will determine which
 * attributes will be filtered in item searches.
 * @author Seraph Softworks
 */
public class ItemSearchOptions extends Data {

    private boolean consider_id;
    private boolean consider_name;
    private boolean consider_type;
    private boolean consider_description;
    private boolean consider_available;
    private boolean consider_deleted;
    private PersonSearchOptions consider_person;

    /**
     * @return the consider_id
     */
    public boolean considerId() {
        return consider_id;
    }

    /**
     * @param consider_id the consider_id to set
     */
    public void setConsiderId(boolean consider_id) {
        this.consider_id = consider_id;
    }

    /**
     * @return the consider_name
     */
    public boolean considerName() {
        return consider_name;
    }

    /**
     * @param consider_name the consider_name to set
     */
    public void setConsiderName(boolean consider_name) {
        this.consider_name = consider_name;
    }

    /**
     * @return the consider_type
     */
    public boolean considerType() {
        return consider_type;
    }

    /**
     * @param consider_type the consider_type to set
     */
    public void setConsiderType(boolean consider_type) {
        this.consider_type = consider_type;
    }

    /**
     * @return the consider_description
     */
    public boolean considerDescription() {
        return consider_description;
    }

    /**
     * @param consider_description the consider_description to set
     */
    public void setConsiderDescription(boolean consider_description) {
        this.consider_description = consider_description;
    }

    /**
     * @return the consider_available
     */
    public boolean considerAvailable() {
        return consider_available;
    }

    /**
     * @param consider_available the consider_available to set
     */
    public void setConsiderAvailable(boolean consider_isAvailable) {
        this.consider_available = consider_isAvailable;
    }

    /**
     * @return the consider_deleted
     */
    public boolean considerDeleted() {
        return consider_deleted;
    }

    /**
     * @param consider_deleted the consider_deleted to set
     */
    public void setConsiderDeleted(boolean consider_deleted) {
        this.consider_deleted = consider_deleted;
    }

    /**
     * @return the consider_person
     */
    public PersonSearchOptions considerPerson() {
        return consider_person;
    }

    /**
     * @param consider_person the consider_person to set
     */
    public void setConsiderPerson(PersonSearchOptions consider_person) {
        this.consider_person = consider_person;
    }

    @Override
    public void reset() {
        setConsiderAvailable(false);
        setConsiderDeleted(false);
        setConsiderDescription(false);
        setConsiderId(false);
        setConsiderName(false);
        setConsiderType(false);
        setConsiderPerson(null);
    }

    public String getItemOrderString() {
        String query = "";
        if (consider_description)
            query += " order by item.description ";
        else if (consider_name)
            query += " order by item.name ";
        else if (consider_type)
            query += " order by item.type ";
        else if (consider_id)
            query += " order by item.id ";
        else if (consider_person != null)
            query += " order by item.person ";
        return query;
    }

    public boolean itemOrderSpecified() {
        return consider_id ^ consider_name ^ consider_type ^ consider_description ^ consider_available ^ consider_deleted ^ consider_person != null;
    }

    public boolean itemOptionsSpecified() {
        return consider_id || consider_name || consider_type || consider_description || consider_available || consider_deleted || consider_person != null;
    }

}
